<?php

	/**
	 * @copyright Apache License 2.0
	 * @author Michael Giddens, SilverBiology
	 * @website http://code.google.com/p/species-land-management/
	*/
#	require_once( BASE_PATH . "api/config.php");	
	require_once( BASE_PATH . "resources/api/classes/class.mysqlidatabase.php");
	require_once( BASE_PATH . "resources/api/classes/class.misc.php");
#	require_once( BASE_PATH . "api/classes/class.col.php");
	require_once( BASE_PATH . "resources/api/classes/class.waflora.php");
	require_once( BASE_PATH . "resources/api/classes/class.pugetsound-test.php");
	require_once( BASE_PATH . "resources/api/classes/class.pugetsound-land.php");
	require_once( BASE_PATH . "resources/api/classes/class.pugetsound-event.php");
	require_once( BASE_PATH . "resources/api/classes/class.pugetsound-dwc.php");

	Class PugetSound {
	
		public $db;

		function __construct() {
			$this->load();
			$this->flb = new FloodBlocker ( sys_get_temp_dir() . '/tmp-ips/' );
			$this->land = new Land();
			$this->event = new Event();
			$this->dwc = new DWC();
//			$this->col = new COL();
			global $waflora;
			$this->waflora = new WAFlora( $waflora );

			$this->land->db = &$this->db;
			$this->event->db = &$this->db;
			$this->dwc->db = &$this->db;

		}

		function load() {

			Global $mysql_host, $mysql_name, $mysql_pass, $mysql_user,$record;
			
			$connection_string="server=$mysql_host; database=$mysql_name; username=$mysql_user; password=$mysql_pass;";	
			$this->db = new MysqliDatabase($connection_string);
			$this->logger->_db = &$this->db;
			return( true );

		}
		
		function error($code) {
			$er = array (
				 1  => 'Not A Valid Command!'
				,2  => 'User Not Logged in'
				,3  => 'Title Should be given'
				,4  => 'Not an allowed Value for Field'
				,5  => 'Not an allowed Value for Sort'
				,6  => 'Not an allowed Value for Private'
				,7  => 'Not a Valid Id'
				,8  => 'GlobalUniqueIdentifier should be Specified'
				,9  => 'Land Id should be Specified'
				,10 => 'Not a Valid Land Id'
				,9  => 'col_id should be Specified'
				,11 => 'Species record was not removed because you do not have permission or not found.'
				,12 => 'Event record was not removed because you do not have permission or not found.'
			);
			return $er[$code];
		}
	}
	
?>